package com.lcf.app.quartz.job;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.time.LocalDateTime;

/**
 * @author ChenFei
 * @date 2022/1/22
 * 任务主要执行逻辑
 */
@Slf4j
public class MyJob extends QuartzJobBean {

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        //https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#io.quartz
        //https://www.w3cschool.cn/quartz_doc/quartz_doc-1xbu2clr.html
        JobDataMap tData = jobExecutionContext.getTrigger().getJobDataMap();
        JobDataMap jData = jobExecutionContext.getJobDetail().getJobDataMap();
        //log.info("tData : {}", JSON.toJSONString(tData));
        log.info("jData : {}", JSON.toJSONString(jData));
        //log.info("MyJob : {}", LocalDateTime.now());
        log.info("-------------------------------------------------------------------------------");
    }

}
